﻿#ifndef LOGMODEL_H
#define LOGMODEL_H

#include <QObject>
#include <QAbstractTableModel>
#include <QVector>
#include "logentry.h"

class LogModel : public QAbstractTableModel
{
    Q_OBJECT

public:
    enum Columns {
        Timestamp,
        ThreadID,
        FileName,
        LineNumber,
        Level,
        Content,
        ColumnCount
    };

    explicit LogModel(QObject* parent = nullptr);

    int rowCount(const QModelIndex& parent = QModelIndex()) const override;
    int columnCount(const QModelIndex& parent = QModelIndex()) const override;
    QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
    QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;

    void addEntries(const QVector<LogEntry>& entries);
    void clear();

    void setFilter(const QString& thread, const QString& level, const QString& keyword);

private:
    QVector<LogEntry> m_allEntries;
    QVector<LogEntry> m_filteredEntries;

    QString m_threadFilter;
    QString m_levelFilter;
    QString m_keywordFilter;
};

#endif // LOGMODEL_H
